//
//  SearchFirstTableViewCell.m
//  PaiLeXiongProject
//
//  Created by 小獾科技 on 2017/8/30.
//  Copyright © 2017年 小獾科技. All rights reserved.
//

#import "SearchFirstTableViewCell.h"


@interface SearchFirstTableViewCell ()
@property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *detailLabel;
@property (nonatomic, strong) UIImageView *starImg;
@property (nonatomic, strong) UILabel *distanceLabel;
@property (nonatomic, strong) UILabel *photoLabel;
@end
@implementation SearchFirstTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        _imgView = [UIImageView new];
        _imgView.layer.backgroundColor = ColorCyan.CGColor;
        [self addSubview:_imgView];
        [self addSubview:_imgView];
        [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(10);
            make.left.equalTo(self).offset(10);
            make.width.equalTo(@86);
            make.height.equalTo(@86);
        }];
        
        _titleLabel = [UILabel new];
        _titleLabel.text = @"爱儿美儿童摄影";
        _titleLabel.textColor = ColorFrom16(0x323232);
        _titleLabel.font = PFRFONT(16);
        [self addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(11);
            make.left.equalTo(_imgView.mas_right).offset(15);
            make.right.equalTo(self).offset(-20);
            make.height.equalTo(@22);
        }];
        
        _detailLabel = [UILabel new];
        _detailLabel.text = @"洋桥／木樨园";
        _detailLabel.textColor = ColorFrom16(0x7F7E7D);
        _detailLabel.font = PFRFONT(16);
        [self addSubview:_detailLabel];
        [_detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLabel.mas_bottom).offset(8);
            make.left.equalTo(_imgView.mas_right).offset(15);
            make.width.equalTo(@180);
            make.height.equalTo(@22);
        }];
        
        _distanceLabel = [UILabel new];
        _distanceLabel.text = @"2.3Km";
        _distanceLabel.textColor = ColorFrom16(0x7F7E7D);
        _distanceLabel.font = PFRFONT(16);
        _distanceLabel.textAlignment = 2;
        [self addSubview:_distanceLabel];
        [_distanceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_detailLabel);
            make.right.equalTo(self).offset(-10);
            make.width.greaterThanOrEqualTo(@60);
            make.height.equalTo(@22);
        }];
        
        _photoLabel = [UILabel new];
        _photoLabel.text = @"摄影";
        _photoLabel.textColor = ColorFrom16(0x2A2F33);
        _photoLabel.font = PFRFONT(12);
        [self addSubview:_photoLabel];
        [_photoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_distanceLabel.mas_bottom).offset(9);
            make.right.equalTo(self).offset(-34);
            make.width.greaterThanOrEqualTo(@26);
            make.height.equalTo(@17);
        }];
        
        
        UIImageView *iv = [UIImageView new];
        iv.image = IMAGE(@"search_photo");
        [self addSubview:iv];
        [iv mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_detailLabel.mas_bottom).offset(12);
            make.right.equalTo(self).offset(-13);
            make.width.equalTo(@12);
            make.height.equalTo(@12);
        }];
        
        UIView *line = [UIView new];
        line.backgroundColor = COLOR_BACKGROUND;
        [self addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_imgView.mas_bottom).offset(17);
            make.left.equalTo(_imgView.mas_right).offset(15);
            make.right.equalTo(self);
            make.height.equalTo(@1);
        }];
    }
    return self;
}

- (void)configViewWithModel:(SearchModel *)model
{
    _titleLabel.text = model.base.store_name;
    _detailLabel.text = model.base.store_sadd;
    _distanceLabel.text = model.base.distance;
    _photoLabel.text = model.base.type_name;
    [_imgView sd_setImageWithURL:[NSURL URLWithString:STRING(model.base.store_img)] placeholderImage:nil];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
